﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Private/Resources/Masterpage/MasterPrivates.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="CallBox.Private.Home._default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Resources/css/jquery.treeview.css" rel="stylesheet" type="text/css" />
    <script src="../Resources/js/jquery.cookie.js" type="text/javascript"></script>
    <script src="../Resources/js/jquery.treeview.js" type="text/javascript"></script>

	<script type="text/javascript">
    
	    $(function () {
	        $("#tree").treeview({
	            collapsed: true,
	            animated: "fast",
	            control: "#sidetreecontrol",
	            prerendered: true,
	            persist: "location"
	        });
	    })
		
	</script>
    <script type="text/javascript">

        jQuery().ready(function () {

            BuildTables();
            FillTable();
            $("#Divdialog").dialog("destroy");

        });

        var lastpartie;

        function BuildTables() {

            try {
                $("#tbjoinpartie").jqGrid({
                    datatype: 'local',
                    colNames: ['','Numero', 'Fecha y Hora','Duracion', 'Grabacion',''],
                    colModel: [
                 { name: 'hidden', index: 'hidden', align: 'left', hidden: true },
                 { name: 'Numero', index: 'Numero', width: 30, align: 'center', sortable: false },
                       { name: 'Date', index: 'Date', width: 25, align: 'center', sortable: false },
                       { name: 'Time', index: 'Time', width: 25, align: 'center', sortable: false },
                        { name: 'Descargar', index: 'Descargar', width: 25, align: 'center' },
                        { name: 'Action', index: 'Action', width: 20, align: 'center' }
                        
                       ],
                    width: 600,
                    height: 'auto',
                    rowNum: 20,
                    pager: '#pagerjoinpartie',
                    caption: "Mensajes de Voz"
                });

                $("#tbjoinpartie").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false });
            } catch (e) { }
        }
        function RowDelete(gr) {

            var row = $('#tbjoinpartie').getRowData(gr);

            var id = row.hidden;


            var qsParm = new Array();
            qsParm = queryString();
            if (qsParm["ex"] != null) {
                if (qsParm["ex"] == "0") {

                    if (confirm("¿Esta seguro de Eliminar permanentemente?")) {
                        success = function (response) {
                            if (response.d)
                                $("#tbjoinpartie").delRowData(gr);
                        };
                        error = function (xhr, ajaxOptions, thrownError) {
                        };
                        Callmethod("default.aspx/delete2",
                '{ Id: "' + id + '"}', success, error);
                    }
                } else {
                    if (confirm("¿Esta seguro de Eliminar ?")) {
                        success = function (response) {
                            if (response.d)
                                $("#tbjoinpartie").delRowData(gr);
                        };
                        error = function (xhr, ajaxOptions, thrownError) {
                        };
                        Callmethod("default.aspx/delete",
                '{ Id: "' + id + '"}', success, error);
                    }
                
                }
            
            
            } else {
                if (confirm("¿Esta seguro de Eliminar?")) {
                    success = function (response) {
                        if (response.d)
                            $("#tbjoinpartie").delRowData(gr);
                    };
                    error = function (xhr, ajaxOptions, thrownError) {
                    };
                    Callmethod("default.aspx/delete",
                '{ Id: "' + id + '"}', success, error);
                }
            }
        }
        function Callmethod(url, data, success, error) {
            $.ajax({
                type: "POST",
                url: url,
                data: data,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: success,
                error: error
            });
        }
        function FillTable() {//SI


            var glancedata = $("#<%=lblData.ClientID%>").val();


            try {
                var obj = $.parseJSON(glancedata);
                var len = obj.length;

                for (var i = 0; i <= len; i++) {
                    var dt = obj[i].ReceiptDateString;
                    var tm = obj[i].Time;
                    var id = obj[i].Id;
                    var qsParm = new Array();
                    var nm ="";
            qsParm = queryString();
            if (qsParm["ex"] != null) {
                if (qsParm["ex"] == "0") {
                    nm = obj[i].Mobile.FirtsName+"("+ obj[i].Mobile.Number+")";
                } else { nm = obj[i].Mobile.Number; }
            }else{  nm = obj[i].Mobile.Number;}
                
                    
                    var audio = "<a target='_blank' href='../Audio/Sleep%20Away.mp3'>Escuchar</a>";
                    
                    var index = i + 1;
                    var row = { Date: dt
                 , Descargar: audio
                 ,Time:tm
                 , hidden: id
                 , Numero: nm
                 , Action: "<div class='Tablebuttons'><input type='button'  class='button' value='Elimnar' style='width: 70px;' title='Elimnar' onclick='RowDelete(" + index + ")' /></div>"
                    };


                    jQuery("#tbjoinpartie").jqGrid('addRowData', i + 1, row);



                }
                //   , Action: "<div class='Tablebuttons'><input type='button'  class='button' value='Edit' title='Edit' style='width: 50px;' onclick='RowEdit(" + index + ")' /> <input type='button'  class='button' value='Detail' style='width: 70px;' title='Delete' onclick='RowDetail(" + index + ")' /></div>" };
            }
            catch (e) { }

        }

        function queryString() {

            var qsParm = new Array();
            var query = window.location.search.substring(1);
            var parms = query.split('&');

            for (var i = 0; i < parms.length; i++) {

                var pos = parms[i].indexOf('=');

                if (pos > 0) {

                    var key = parms[i].substring(0, pos);
                    var val = parms[i].substring(pos + 1);
                    qsParm[key] = val;

                }
            }

            return qsParm;
        }
  
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="contenedor">

<div id="lateral">
<div id="sidetree" style="overflow: scroll; height:530px; max-height:530px;">
  <div class="treeheader">&nbsp;</div>
  <div id="sidetreecontrol"> <a href="?#">Minimizar Todo</a> | <a href="?#">Maximizar Todo</a> </div>

  <ul class="treeview" id="tree">

	<li class="expandable"><div class="hitarea expandable-hitarea"></div><span>UPN</span>
	<ul style="display: none;">
    <li><a href="?ex=1&nm=ZPqP5jZscjAeY%2bWAbmlWETOUFSf88WN7Qn9H8DHKipo%3d">Victor Goicochea(949505052)</a></li>
		<li><a href="?ex=2&nm=Eeo%2fxIpaEacI2ZCHVe%2bGF4CzqyPrCV0fxP30pOpggpk%3d">Max Izquierdo(958748521)</a></li>
		

		<li><a href="?ex=3&nm=C13W2Qw2FXMFecES450G4l%2blQwrvIg0Vbby%2fR0k63Io%3d">Diego Hidalgo(957841524)</a></li>

		<li><a href="?ex=4&nm=2BB6cwEbEUAW3op5KUWzYANa9CT%2fxLyp%2fEd5jMFmC6c%3d">Gino Saavedra(968545414)</a></li>

	</ul>
	</li>

	

	<li class="expandable"><div class="hitarea expandable-hitarea"></div><span>Otros</span>
	<ul style="display: none;">

		<li><a href="?ex=5&nm=%2bhYOspERtmc0Eow2AfE76hl%2b0nxRqsp3wFo8DEiVV1g%3d">Jose Fuentes(958525254)</a></li>

		<li><a href="?ex=6&nm=wLfXwtXRLgNUe%2fjDAr2u%2fd8Xc3MfgaKprzJwKPpUsQg%3d">Genesis Tapia(969989896)</a></li>

		<li><a href="?ex=7&nm=5o5Z3q6AR2pGPWBwt9TTs2%2b7hJ0iP0VDGyl6YqBYoE0%3d">Joel Gonzales(951525414)</a></li>

	</ul>
	</li>
    <li><a href="?ex=0">Papelera</a></li>
	</ul>
</div>
</div>
    
<div id="principal" style="height:530px; max-height:530px;">
   <h2 style="color:#38854D;"> <asp:Label ID="lblName" runat="server" Text=""></asp:Label></h2>
<table id="tbjoinpartie">
    </table>
    <div id="pagerjoinpartie"></div>

    <asp:HiddenField  runat="server" ID="lblData"/>
</div>

</div>
</asp:Content>
